var express = require("express");
var router = express.Router();
const path = require("path");
const multer = require("multer");
const upload = multer({ dest: "uploads/" });
const multerConfig = require("../../utils/multerConfig");
/**sss
 * 图片上传
 */
router.post("/uploadImgApi", async (req, res, next) => {
  console.log("jjsjsjsjjs", req.headers.body);
  res.send("122");
});

router.post("/upload", multerConfig.single("file"), (req, res, next) => {
  console.log("res",res.req.file,typeof res)
  let resData = {code:200,fileID:''}
  res.send("200");
  // listHouseInfo(req.body).then(list=>{
  //     debug && console.log(list)
  //     new Result(list).success(res)
  //   }).catch(err=>{
  //     next(boom.badImplementation(err))
  //   })
})

// 下载
router.get("/download", (req, res, next) => {
  debug && console.log("/file/download", req.body);
  console.log(req.file);
  let filePath = path.join(
    __dirname,
    "../static/uploads/1692155801705/1692155801706.png"
  );
  console.log(__dirname);
  res.download(filePath);
  // new Result(req.file).success(res)
  // listHouseInfo(req.body).then(list=>{
  //     debug && console.log(list)
  //     new Result(list).success(res)
  //   }).catch(err=>{
  //     next(boom.badImplementation(err))
  // })
});

module.exports = router;
